"use strict";

module.exports = core;
const log = require("@along-dev/log");
const colors = require("colors");
const constant = require("./const");
const semver = require("semver");

function core() {
  try {
    checkPackageVersion();
    checkNodeVersion();
  } catch (e) {
    log.error(e.message);
  }
}

const pkg = require("../package.json");
function checkPackageVersion() {
  log.info("cli", pkg.version);
}

function checkNodeVersion() {
  // 获取当前node版本
  const currentVersion = process.version;
  const lowestVersion = constant.LOWEST_NODE_VERSION;
  if (semver.gte(lowestVersion, currentVersion)) {
    throw new Error(colors.red(`node版本过低，最低版本为${lowestVersion}`));
  }
}
